#include "stdio.h"

void printArray(int** priceArray,int len,int len2)
{
    for(int i=0;i<len;i++)
    {
        for(int j=0;j<len2;j++)
        {
            printf("%d\t\t\t",priceArray[i][j]);
        }
        printf("\n");
    }
    printf("\n");
    

}

int main()
{
    int n,m,num;
    scanf("%d %d %d",&n,&m,&num);
    int** inputI=new int*[n];
    char** inputC=new char*[n];
    int** bag=new int*[n+1];
    int* bag_len=new int[m];
    int i,j,k;

    bag[n]=new int[m];
    for(i=0;i<n;i++)
    {
        inputI[i]=new int[m];
        inputC[i]=new char[m];
        bag[i]=new int[m];
       
        for(j=0;j<m;j++)
        {
            scanf("%d %c",&inputI[i][j],&inputC[i][j]);
        }
    }

    int score;
    int zidan;
    for(j=0;j<m;j++)
    {   
        score=0;
        zidan=0;
        bag[0][j]=0;
        for(k=n-1;k>=0;k--)
        {
            score+=inputI[k][j];
            if(inputC[k][j]!='Y')
            {
                zidan++;
            }
            bag[zidan][j]=score;
            if(zidan>=num)
            {
                break;
            }
        }
        bag_len[j]=zidan+1;
    }

    printArray(bag,n+1,m);

    for(i=0;i<n;i++)
    {
        delete inputI[i];
        delete inputC[i];
    }
    delete inputI;
    delete inputC;

    int len=num+1;
    int** dp=new int*[m];
    n++;

    for(j=0;j<m;j++)
    {
        dp[j]=new int[len];
        for(i=0;i<len;i++)
        {
            dp[j][i]=0;
        }
    }
    
    for(i=0;i<len;i++)
    {
        if(i<bag_len[0])
        {
             dp[0][i]=bag[i][0];
        }
        else{
            dp[0][i]=bag[bag_len[0]-1][0];
        }
    }

    int max;
    for(j=1;j<m;j++)
    {
        for(i=0;i<len;i++)
        {
            max=0;
            for(k=0;k<bag_len[j]&&k<=i;k++)
            {
               int tmpIndex=i-k;
               score=dp[j-1][tmpIndex]+(k<bag_len[j]?bag[k][j]:bag[bag_len[j]-1][j]);
               if(max<score)
               {
                   max=score;
               }
            }
            dp[j][i]=max;
        }
    }

    // printArray(dp,m,len);

    printf("%d\n",dp[m-1][num]);
    for(j=0;j<n;j++)
    {   
       delete bag[j];
    }
    delete bag;
    delete bag_len;

    for(j=0;j<m;j++)
    {
        delete dp[j];
    }
    delete dp;

    

    return 0;
}